<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>社区健康系统登录</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/login.css">

    <!-- 新增自定义样式 -->
    <style>
        :root {
            --primary-color: #00c6a7;
            --secondary-color: #008f7a;
            --bg-gradient: linear-gradient(135deg, #e6f7f5, #f0ffff);
        }

        body {
            min-height: 100vh;
            margin: 0;
            background: var(--bg-gradient);
            font-family: 'Segoe UI', sans-serif;
        }

        .auth-wrapper {
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            padding: 2rem;
        }

        .auth-card {
            background: white;
            border-radius: 20px;
            box-shadow: 0 8px 24px rgba(0, 143, 122, 0.12);
            padding: 3.5rem 3rem;
            width: 100%;
            max-width: 450px;
            transition: transform 0.3s ease;
        }

        .auth-card:hover {
            transform: translateY(-5px);
        }

        .logo-container {
            margin-bottom: 2.5rem;
            text-align: center;
        }

        .logo-icon {
            font-size: 2.8rem;
            color: var(--primary-color);
            margin-bottom: 0.5rem;
        }

        .auth-title {
            color: var(--secondary-color);
            font-size: 1.8rem;
            font-weight: 600;
            line-height: 1.2;
        }

        .form-group {
            margin-bottom: 1.8rem;
        }

        .form-label {
            display: block;
            margin-bottom: 0.6rem;
            color: #333;
            font-weight: 500;
            font-size: 0.95rem;
        }

        .input-group {
            position: relative;
            border-radius: 12px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        }

        .input-group-text {
            background: #f8f9fa;
            border: none;
            width: 48px;
            height: 48px;
            border-radius: 10px 0 0 10px;
            font-size: 1.2rem;
        }

        .form-control {
            height: 48px;
            border-radius: 0 10px 10px 0;
            font-size: 1rem;
            transition: box-shadow 0.3s ease;
        }

        .form-control:focus {
            box-shadow: 0 0 0 3px rgba(0, 202, 167, 0.2);
            outline: none;
        }

        .password-toggle {
            position: absolute;
            right: 1rem;
            top: 50%;
            transform: translateY(-50%);
            cursor: pointer;
            color: #666;
            transition: color 0.3s ease;
        }

        .password-toggle:hover {
            color: var(--primary-color);
        }

        .btn-primary {
            background: var(--primary-color);
            border: none;
            padding: 0.8rem 1.5rem;
            border-radius: 10px;
            font-size: 1rem;
            font-weight: 500;
            letter-spacing: 0.8px;
            transition: all 0.3s ease;
        }

        .btn-primary:hover {
            background: var(--secondary-color);
            transform: scale(1.02);
            box-shadow: 0 4px 12px rgba(0, 202, 167, 0.2);
        }

        .animated-alert {
            animation: fadeInUp 0.4s ease;
        }

        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
    </style>
</head>
<body>
<div id="login" class="auth-wrapper">
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-8 col-lg-6">
                <div class="auth-card mx-auto">
                    <div class="logo-container">
                        <i class="bi bi-heart-pulse-fill logo-icon"></i>
                        <h2 class="auth-title">社区健康监测系统</h2>
                    </div>

                    <c:if test="${not empty errorMessage}">
                        <div class="alert alert-danger animated-alert mb-4">
                                ${errorMessage}
                        </div>
                    </c:if>

                    <form id="loginForm"
                          action="${pageContext.request.contextPath}/login"
                          method="post"
                          novalidate>
                        <div class="form-group">
                            <label for="username" class="form-label">用户名</label>
                            <div class="input-group">
                                <span class="input-group-text">
                                    <i class="bi bi-person-fill"></i>
                                </span>
                                <input type="text"
                                       id="username"
                                       name="username"
                                       class="form-control"
                                       placeholder="请输入用户名"
                                       required>
                            </div>
                        </div>

                        <div class="form-group position-relative">
                            <label for="password" class="form-label">密码</label>
                            <div class="input-group">
                                <span class="input-group-text">
                                    <i class="bi bi-lock-fill"></i>
                                </span>
                                <input type="password"
                                       id="password"
                                       name="password"
                                       class="form-control"
                                       placeholder="请输入密码"
                                       required>
                            </div>
                        </div>

                        <button type="submit" class="btn btn-primary btn-lg w-100">
                            登录 <i class="bi bi-box-arrow-in-right ms-1"></i>
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 引入 jQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- 引入 Bootstrap JS -->
<script src="${pageContext.request.contextPath}/static/js/bootstrap.bundle.min.js"></script>
<!-- 自定义JS -->
<script src="${pageContext.request.contextPath}/static/js/app.js"></script>
<script>
    // 优化后的密码可见性切换
    function togglePasswordVisibility(event) {
        event.preventDefault();
        const passwordField = document.getElementById('password');
        const toggleIcon = event.currentTarget.querySelector('i');

        if (passwordField.type === 'password') {
            passwordField.type = 'text';
            toggleIcon.classList.replace('bi-eye-slash', 'bi-eye');
        } else {
            passwordField.type = 'password';
            toggleIcon.classList.replace('bi-eye', 'bi-eye-slash');
        }
    }
</script>

</body>
</html>